<?php
$sids = $_SESSION["ArraySec"];
if($_SESSION['Permit']==1)
 { $sql = "Select id from tblarticle order by section_id";
 }
 else
$sql = "Select id from tblarticle where section_id  in ($sids) order by section_id";
$rs = mysql_query($sql);

$aids ="";
while($aid = mysql_fetch_object($rs)){
	$aids.=$aid->id.",";	
}
$aids = substr($aids,0,strlen($aids)-1);

$sql = "Select tblresource.*,tblarticle.id as aid From tblresource inner join tblarticle on tblresource.article_id = tblarticle.id where tblarticle.id in ($aids)";


$rs = mysql_query($sql)or die(mysql_error());

?>
<script language="javascript" type="text/javascript">
function delResource(rid){
	if(confirm("Bạn có chắc chắn muốn xóa tài nguyên này?")){
		location="rsd?rid="+rid;
	}
}
</script>
<table width="100%">
	<tr>
		<td colspan="5" ><h3>Quản lý tài nguyên</h3></td>
		<td align="right" colspan="2">
			<a href="rsa" title="Tạo tài nguyên mới">
				<img src="img/Add.png" style="border:none;" width="32" height="32"/>
			</a>
		</td>
	</tr>
	
	<tr style="background: #008000;color: white;height:30px;">
		<th width="5%">STT</th>
		<th width="27%">Tên tiếng Việt</th>
		<th width="27%">Tên tiếng Anh</th>
		<th  width="10%">Thể loại</th>
		<th width="10%">Link</th>
		<th width="10%">Mã bài viết</th>
		<th width="11%">Thực hiện</th>
	</tr>
	<?php
		$i=1;
		while($resource = mysql_fetch_object($rs)){
	?>
		<tr style="background:#e7e7e7;">
			<td align='center'><?php echo $i++; ?></td>
			<td><?php echo $resource->vi_name;?></td>
			<td><?php echo $resource->en_name;?></td>
			<td align="center"><?php echo (($resource->type==1)?"Video":"Tài liệu");?></td>
			<td align="center"><a href='<?php echo $resource->link;?>' title='<?php echo $resource->link?>'>Link</a></td>
			<td align='center'><a href='editarticle?aid=<?php echo $resource->article_id;?>'> Xem</a></td>
			<td align='center'><a href='rse?rid=<?php echo $resource->id;?>'>Sửa</a> | <a href='' onclick='delResource(<?php echo $resource->id ?>);return false;'>Xóa</a></td>
		</tr>
	<?php	
		}
	?>
</table>
